// 模拟数据生成器
import { PictureBook, Activity, User, Child } from '@/stores/appStore';

// 生成随机ID
const generateId = () => Math.random().toString(36).substr(2, 9);

// 绘本分类
const bookCategories = [
  '友情', '自然', '情绪管理', '科普', '传统文化', '数学启蒙', '艺术启蒙', '安全意识'
];

// 活动分类
const activityCategories = [
  '绘本故事会', '亲子手工课', '周末亲子营', '节日主题活动', '科学实验', '艺术创作'
];

// 兴趣标签
const interests = [
  '动物', '植物', '星空', '海洋', '绘画', '音乐', '手工', '运动', '阅读', '探索'
];

// 模拟绘本数据
export const mockBooks: PictureBook[] = [
  {
    id: generateId(),
    title: '小熊和小兔的友谊',
    author: '李明华',
    illustrator: '王小红',
    publisher: '童趣出版社',
    coverImage: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=A%20heartwarming%20illustration%20of%20a%20little%20bear%20and%20rabbit%20hugging%2C%20soft%20pastel%20colors%2C%20children%27s%20book%20style%2C%20gentle%20and%20cute&image_size=square',
    previewImages: [
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20bear%20and%20rabbit%20playing%20together%20in%20a%20meadow%2C%20colorful%20flowers%2C%20soft%20illustration%20style&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20bear%20sharing%20honey%20with%20rabbit%2C%20warm%20and%20friendly%20scene%2C%20children%27s%20book%20illustration&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20bear%20and%20rabbit%20looking%20at%20stars%20together%2C%20peaceful%20night%20scene%2C%20gentle%20colors&image_size=square'
    ],
    description: '一个关于友谊的温暖故事，讲述了小熊和小兔如何从陌生人变成最好的朋友。通过日常生活中的小事情，孩子们可以学会分享、关心和互相帮助的重要性。',
    ageRange: '3-6岁',
    category: '友情',
    tags: ['友谊', '分享', '互助', '温暖'],
    rating: 4.8,
    readCount: 1250,
    price: 28.8,
    pages: 32,
    stock: 50,
    originalPrice: 35.0,
    reviews: [
      {
        userName: '快乐妈妈',
        rating: 5,
        comment: '孩子很喜欢这本书，故事很温暖，插图也很美！',
        date: '2024-01-15'
      },
      {
        userName: '小明爸爸',
        rating: 4,
        comment: '很好的友谊教育绘本，推荐给其他家长。',
        date: '2024-01-10'
      }
    ]
  },
  {
    id: generateId(),
    title: '小种子的大梦想',
    author: '张春华',
    illustrator: '刘美丽',
    publisher: '自然出版社',
    coverImage: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=A%20tiny%20seed%20growing%20into%20a%20beautiful%20tree%2C%20stages%20of%20growth%2C%20educational%20children%27s%20book%20illustration%2C%20soft%20colors&image_size=square',
    previewImages: [
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Seed%20in%20the%20soil%20with%20roots%20growing%2C%20educational%20nature%20illustration%2C%20gentle%20colors&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Small%20plant%20sprouting%20with%20leaves%2C%20sunshine%20and%20rain%2C%20educational%20diagram%20style&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Full-grown%20tree%20with%20fruits%20and%20flowers%2C%20cycle%20of%20life%20illustration%2C%20children%27s%20book%20style&image_size=square'
    ],
    description: '跟随一颗小种子的成长历程，孩子们可以了解植物生长的奥秘。这本书用简单的语言和美丽的插图，讲述了生命成长的奇迹和坚持梦想的重要性。',
    ageRange: '4-8岁',
    category: '自然',
    tags: ['生命教育', '自然科学', '成长', '梦想'],
    rating: 4.6,
    readCount: 980,
    price: 32.0,
    pages: 28,
    stock: 30,
    originalPrice: 38.0,
    reviews: [
      {
        userName: '自然爱好者',
        rating: 5,
        comment: '很好的自然科学启蒙书，孩子学到了很多！',
        date: '2024-01-20'
      }
    ]
  },
  {
    id: generateId(),
    title: '情绪小怪兽',
    author: '王心理',
    illustrator: '陈情绪',
    publisher: '心理健康出版社',
    coverImage: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=A%20cute%20little%20monster%20with%20different%20emotional%20expressions%2C%20colorful%20and%20friendly%2C%20children%27s%20book%20illustration%2C%20soft%20pastel%20colors&image_size=square',
    previewImages: [
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20monster%20feeling%20angry%2C%20red%20color%20theme%2C%20emotional%20education%20illustration&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20monster%20feeling%20sad%2C%20blue%20color%20theme%2C%20comforting%20scene%2C%20emotional%20learning&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Little%20monster%20feeling%20happy%2C%20yellow%20color%20theme%2C%20celebration%20scene%2C%20positive%20emotions&image_size=square'
    ],
    description: '帮助孩子认识和管理自己的情绪。通过可爱的情绪小怪兽形象，让孩子们学会识别不同的情绪，并学会用正确的方式表达和处理情绪。',
    ageRange: '3-7岁',
    category: '情绪管理',
    tags: ['情绪认知', '心理健康', '情绪管理', '自我表达'],
    rating: 4.9,
    readCount: 1580,
    price: 29.9,
    pages: 24,
    stock: 40,
    originalPrice: 36.0,
    reviews: [
      {
        userName: '心理老师',
        rating: 5,
        comment: '很好的情绪管理绘本，推荐！',
        date: '2024-01-18'
      }
    ]
  },
  {
    id: generateId(),
    title: '数字王国的秘密',
    author: '刘数学',
    illustrator: '赵图形',
    publisher: '数学启蒙出版社',
    coverImage: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Numbers%20and%20mathematical%20symbols%20as%20friendly%20characters%20in%20a%20magical%20kingdom%2C%20educational%20math%20book%20cover%2C%20colorful%20and%20fun&image_size=square',
    previewImages: [
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Numbers%201%20to%2010%20as%20happy%20characters%20dancing%20together%2C%20educational%20illustration%2C%20bright%20colors&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Simple%20addition%20and%20subtraction%20scenes%20with%20friendly%20numbers%2C%20educational%20math%20illustration&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Shape%20characters%20-%20circle%2C%20square%2C%20triangle%20having%20fun%2C%20geometry%20learning%20illustration&image_size=square'
    ],
    description: '用有趣的故事和可爱的数字角色，让孩子们在玩乐中学习基础数学概念。从1到10，从加减法到几何图形，开启孩子的数学思维。',
    ageRange: '4-8岁',
    category: '数学启蒙',
    tags: ['数学启蒙', '数字认知', '逻辑思维', '教育启蒙'],
    rating: 4.5,
    readCount: 750,
    price: 26.8,
    pages: 20,
    stock: 25,
    originalPrice: 32.0,
    reviews: [
      {
        userName: '数学老师',
        rating: 4,
        comment: '数学启蒙很棒！',
        date: '2024-01-22'
      }
    ]
  },
  {
    id: generateId(),
    title: '颜色的魔法',
    author: '李彩虹',
    illustrator: '王色彩',
    publisher: '艺术启蒙出版社',
    coverImage: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Colorful%20paint%20palette%20and%20brushes%20creating%20a%20magical%20rainbow%20scene%2C%20art%20education%20book%20cover%2C%20vibrant%20and%20creative&image_size=square',
    previewImages: [
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Primary%20colors%20-%20red%2C%20blue%2C%20yellow%20as%20playful%20characters%2C%20color%20mixing%20education%20illustration&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Color%20mixing%20scenes%20showing%20how%20colors%20blend%2C%20educational%20art%20illustration%2C%20gentle%20and%20fun&image_size=square',
      'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Beautiful%20rainbow%20and%20colorful%20artwork%20created%20by%20children%2C%20celebration%20of%20creativity%2C%20inspiring%20scene&image_size=square'
    ],
    description: '通过有趣的色彩实验和创意活动，让孩子发现颜色的奥秘。从基础的三原色到丰富的色彩变化，培养孩子的艺术感知力和创造力。',
    ageRange: '3-8岁',
    category: '艺术启蒙',
    tags: ['色彩认知', '艺术启蒙', '创造力', '美育教育'],
    rating: 4.7,
    readCount: 890,
    price: 31.5,
    pages: 26,
    stock: 35,
    originalPrice: 39.0,
    reviews: [
      {
        userName: '艺术妈妈',
        rating: 5,
        comment: '颜色很漂亮，孩子很喜欢！',
        date: '2024-01-25'
      }
    ]
  }
];

// 模拟活动数据
export const mockActivities: Activity[] = [
  {
    id: generateId(),
    title: '春季绘本故事会 - 友谊的种子',
    description: '在春暖花开的季节里，我们一起阅读关于友谊的温暖绘本，通过互动游戏和手工制作，让孩子们学会珍惜友谊，培养社交能力。',
    image: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Children%20sitting%20in%20a%20circle%20listening%20to%20storytelling%2C%20spring%20decorations%2C%20warm%20and%20cozy%20library%20setting%2C%20educational%20activity%20scene&image_size=square',
    date: '2024-03-15',
    time: '10:00-11:30',
    category: '绘本故事会',
    ageRange: '3-8岁',
    location: '北京市朝阳区儿童图书馆',
    spots: 5,
    rating: 4.8,

    price: 68,



    organizer: '绘本岛故事团队',


  },
  {
    id: generateId(),
    title: '亲子手工课 - 春天的花朵',
    description: '家长和孩子一起动手制作美丽的纸花，学习春天的知识，培养动手能力和创造力。所有材料由我们提供，成品可以带回家装饰。',
    image: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Parents%20and%20children%20making%20paper%20flowers%20together%2C%20colorful%20craft%20materials%20on%20table%2C%20happy%20family%20activity%20scene%2C%20creative%20learning%20environment&image_size=square',
    date: '2024-03-20',
    time: '14:00-16:00',
    category: '亲子手工课',
    ageRange: '4-10岁',
    location: '上海市浦东新区艺术中心',
    spots: 7,
    rating: 4.6,

    price: 128,



    organizer: '创意手工工作室',


  },
  {
    id: generateId(),
    title: '周末亲子营 - 小小农场主',
    description: '带孩子体验农场生活，学习植物种植知识，与小动物亲密接触。一天的活动包括种植体验、动物喂养、农产品采摘等，让孩子亲近自然。',
    image: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Children%20feeding%20farm%20animals%2C%20goats%20and%20rabbits%2C%20sunny%20farm%20setting%2C%20educational%20nature%20experience%2C%20happy%20kids%20learning%20about%20animals&image_size=square',
    date: '2024-03-23',
    time: '09:00-17:00',
    category: '周末亲子营',
    ageRange: '5-12岁',
    location: '广州市郊区阳光农场',
    spots: 7,
    rating: 4.7,

    price: 298,



    organizer: '自然教育中心',


  }
];

// 模拟用户数据
export const mockUser: User = {
  id: generateId(),
  phone: '138****8888',
  nickname: '绘本妈妈',
  avatar: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Warm%20and%20friendly%20mother%20avatar%2C%20soft%20colors%2C%20gentle%20smile%2C%20parent%20profile%20icon%2C%20clean%20and%20simple%20design&image_size=square',
  favorites: [],
  cart: [],
  orders: [],
  children: [
    {
      id: generateId(),
      name: '小明',
      age: 5,
      gender: 'male',
      interests: ['动物', '绘画', '探索'],
      avatar: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Cute%205-year-old%20boy%20avatar%2C%20curious%20expression%2C%20child%20profile%20icon%2C%20warm%20and%20friendly%20design%2C%20soft%20colors&image_size=square',
      birthDate: '2019-06-15'
    },
    {
      id: generateId(),
      name: '小红',
      age: 8,
      gender: 'female',
      interests: ['阅读', '音乐', '手工'],
      avatar: 'https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=Sweet%208-year-old%20girl%20avatar%2C%20gentle%20smile%2C%20child%20profile%20icon%2C%20warm%20and%20friendly%20design%2C%20soft%20pastel%20colors&image_size=square',
      birthDate: '2016-09-20'
    }
  ],
  currentChildId: ''
};

// 生成更多模拟绘本
export const generateMoreBooks = (count: number): PictureBook[] => {
  const additionalBooks: PictureBook[] = [];
  
  for (let i = 0; i < count; i++) {
    const category = bookCategories[Math.floor(Math.random() * bookCategories.length)];
    const ageMin = Math.floor(Math.random() * 4) + 3; // 3-6岁
    const ageMax = ageMin + Math.floor(Math.random() * 4) + 2; // 年龄范围2-5年
    
    additionalBooks.push({
      id: generateId(),
      title: `${category}主题绘本 ${i + 1}`,
      author: `作者${Math.floor(Math.random() * 20) + 1}`,
      illustrator: `插画师${Math.floor(Math.random() * 15) + 1}`,
      publisher: '童趣出版社',
      coverImage: `https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=${encodeURIComponent(
        `Children's book cover about ${category}, soft and warm illustration style, educational and fun, age appropriate for ${ageMin}-${ageMax} years old`
      )}&image_size=square`,
      previewImages: Array(3).fill(null).map(() => 
        `https://trae-api-us.mchost.guru/api/ide/v1/text_to_image?prompt=${encodeURIComponent(
          `Children's book illustration page about ${category}, educational content, soft colors, age appropriate`
        )}&image_size=square`
      ),
      description: `这是一本关于${category}的优秀绘本，通过生动有趣的故事和精美的插图，帮助孩子们了解和学习相关知识。适合${ageMin}到${ageMax}岁的孩子阅读。`,
      ageRange: `${ageMin}-${ageMax}岁`,
      category,
      tags: [category, '教育', '启蒙'],
      rating: Math.round((Math.random() * 1.5 + 3.5) * 10) / 10,
      readCount: Math.floor(Math.random() * 1000) + 200,
      price: Math.round((Math.random() * 15 + 20) * 10) / 10,
      pages: Math.floor(Math.random() * 20) + 20,
      stock: Math.floor(Math.random() * 50) + 20,
      originalPrice: Math.round((Math.random() * 10 + 30) * 10) / 10,
      reviews: [
        {
          userName: '读者' + Math.floor(Math.random() * 100),
          rating: Math.floor(Math.random() * 2) + 4,
          comment: '很好的绘本，孩子很喜欢！',
          date: '2024-01-' + Math.floor(Math.random() * 28 + 1)
        }
      ]
    });
  }
  
  return additionalBooks;
};